package yaty.lee.study.jdbc.oracle;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
    private final String dbUrl = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
    private final String theUser = "system";
    private final String thePw = "rs3zAThzk1";

    static {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public Connection getConnection() {
        try {
            return DriverManager.getConnection(dbUrl, theUser, thePw);
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }
}
